MRTG Start | Stop | Status | Restart
Publicado por Fernando Ribeiro 08/03/2005
[ Hits: 12.642 ]
Homepage: http://www.vivaolinux.com.br/~fernandofat
Este script manipula o daemon do MRTG das seguintes maneiras:
Start | Stop | Status | Restart
Os caminhos dos arquivos do MRTG podem variar dependendo de como o MRTG foi compilado, neste caso é só alterar as variáveis no começo do script.
No meu Red Hat coloquei o script em /etc/rc.d/init.d e ficou muito bom, facilitando bastante.
#!/bin/bash
# Configuration
MRTG_BIN=/usr/local/mrtg-2/bin/mrtg
MRTG_CONF=/etc/mrtg.conf
MRTG_LOCK_FILE=/var/lock/subsys/mrtg
MRTG_PID_FILE=/var/run/mrtg.pid
MRTG_LOG_FILE=/var/log/mrtg/mrtg.log
getpid ()
{
if [ -f $MRTG_PID_FILE ]; then
MRTG_PID=`head -n 1 $MRTG_PID_FILE`
return 0
else
echo "Error - PID file does not exist!!!"
exit 1
fi
}
startmrtg ()
{
if [ -f $MRTG_PID_FILE ]; then
echo "Can not start MRTG is already running!!!"
statusmrtg
return 1
else
echo "Starting MRTG:"
env LANG=C $MRTG_BIN $MRTG_CONF --lock-file $MRTG_LOCK_FILE \
--pid-file=$MRTG_PID_FILE \
--logging $MRTG_LOG_FILE > /dev/null
sleep 5
if [ -f $MRTG_PID_FILE ]; then
echo "MRTG started OK!!!"
statusmrtg
return 0
else
echo "MRTG did NOT start, check configuration!!!"
statusmrtg
return 1
fi
fi
}
stopmrtg ()
{
if [ -f $MRTG_PID_FILE ]; then
getpid
echo "Stopping MRTG:"
kill $MRTG_PID
rm -f $MRTG_LOCK_FILE
while [ -f $MRTG_PID_FILE ]
do
sleep 1
done
echo "MRTG stopped OK!!!"
statusmrtg
return 0
else
echo "MRTG was not running!!!"
statusmrtg
return 1
fi
}
statusmrtg ()
{
if [ -f $MRTG_PID_FILE ]; then
getpid
echo "Status MRTG: Running!"
echo "Process ID: $MRTG_PID"
return 0
else
echo "Status MRTG: Not running!"
return 1
fi
}
case "$1" in
start)
startmrtg
;;
stop)
stopmrtg
;;
status)
statusmrtg
;;
restart)
stopmrtg
startmrtg
;;
*)
echo "Usage: mrtg {start|stop|restart|status}"
exit 1
;;
esac
KDE 4.1.1 no Slackware Linux 12.1
Verificar o tipo dos arquivo de um diretório
Relógio em tempo real no terminal
Nenhum comentário foi encontrado.
LazyDocker – Interface de Usuário em Tempo Real para o Docker
Instalando COSMIC no Linux Mint
Turbinando o Linux Mint: o poder das Nemo Actions
Inteligência Artificial no desenvolvimento de software: quando começar a usar?
[Resolvido] Algo deu errado ao abrir seu perfil
Usando o VNSTAT para medir o seu consumo de internet
Habilitando clipboard manager no ambiente COSMIC
Não estou conseguindo fazer funcionar meu Postfix na versão 2.4 no Deb... (2)
Quando vocês pararam de testar distros? (10)









